<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <script src="../js/vue2-dev.js"></script>
    </head>
    <body>
        <div id="root"></div>
    </body>
    <script>
        Vue.config.productionTip = false;

        // 1.student组件
        const student = {
            template: `
                <div>
                    <p>{{name}}</p>
                </div>
            `,
            data() {
                return {
                    name: "xuhu",
                };
            },
        };

        // 2.school组件
        const school = {
            template: `
                <div>
                    <p>{{name}}</p>
                    <student></student>
                </div>
            `,
            data() {
                return {
                    name: "小哈佛幼儿园",
                };
            },
            components: {
                student,
            },
        };

        // 3.医生组件
        const doctor = {
            template: `
                <div>
                    <p>{{name}}</p>
                </div>
            `,
            data() {
                return {
                    name: "Tony老师",
                };
            },
        };

        // 4.医院组件
        const hospital = {
            template: `
                <div>
                    <p>{{name}}</p>
                    <doctor></doctor>
                </div>
            `,
            data() {
                return {
                    name: "第一中心医院",
                };
            },
            components: {
                doctor,
            },
        };

        // 5.app总组件
        const app = {
            template: `
                <div>
                    <school></school>
                    <hospital></hospital>
                </div>
            `,
            components: {
                school,
                hospital,
            },
        };

        new Vue({
            el: "#root",
            template: `
            <div>
                <app></app>
            </div>
            `,
            components: {
                app,
            },
        });
    </script>
</html>
